import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MyButton extends StatelessWidget {
  final VoidCallback onPressed;
  final String title;

  const MyButton({Key key, @required this.onPressed, @required this.title}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 10),
      width: ScreenUtil().setWidth(200),
      height: ScreenUtil().setHeight(50),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(50),
        //漸變色
        gradient: LinearGradient(colors: [
          Color(0xffa2c542),
          Color(0xff2e80c5)
        ]),
      ),
      child: RaisedButton(
        onPressed:onPressed,
        child: Text(
          title,
          style: TextStyle(
              fontWeight: FontWeight.bold,
              fontSize: ScreenUtil().setSp(16),
              fontFamily: "SemiBold"),
        ),
        textColor: Colors.white,
        // 设为透明色
        color: Colors.transparent,
        disabledColor: Color(0Xff9fa3b9),
        //按鈕被禁用時候的顏色
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(30),
        ),
      ),
    );
  }
}
